"""


"""

from flask import Flask
from flask import session
from flask_sqlalchemy import SQLAlchemy
from flask_session import Session
import redis

app = Flask(__name__)


class Config(object):
    DEBUG = True
    SECRET_KEY = "(&*^$%^&^#&$&*#$*#%&#*%&#"
    # 对mysql数据库进行配置
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/info_gz10"
    SQLALCHEMY_TRACK_MODIFICATIONS = Flask

    # 对mysql数据库进行配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    # 配置session信息

    SESSION_TYPE = "redis"   # 存储类型
    SESSION_KEY_PREFIX = "Session:"  # 设置前缀
    SESSION_USE_SIGNER = True  # 签名存储
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)  # 制定存储位置
    PERMANENT_SESSION_LIFETIME = 3600*24*2  # 设置session两天有效


# 从类对象中加载配置文件
app.config.from_object(Config)

#创建SQLAlchemy对象
db = SQLAlchemy(app)

# 创建redis仓库
redis_store = redis.StrictRedis(host=Config.REDIS_HOST,port=Config.REDIS_PORT)

#创建Session对象
Session(app)

@app.route('/')
def index():

    # 测试redis
    # redis_store.set("a1", "python")

    # 测试Session
    # session["name"] = "python3"

    return 'index'
if __name__ == '__main__':
    app.run(debug=True)